home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Link change *)
- (* *)
- (* Copyright 1988, 1989, 1990, 1991 by H. Roy Engehausen. All rights *)
- (* reserved. *)
- (* *)
- (*===========================================================================*)
-
- {$O+}
-
- UNIT BBLC;
-
- INTERFACE
-
- PROCEDURE link_start;
- PROCEDURE link_change;
- PROCEDURE link_pending;
-
- IMPLEMENTATION
-
- USES
- bbauxm,
- bbdummy,
- bblog,
- bbmdata,
- bbmess,
- bbmisc4,
- bbsess,
- bbsrt,
- bbstr,
- bbtask,
- bbuf,
- bbwin;
-
- (*===========================================================================*)
- (* Link Status Start *)
- (*===========================================================================*)
-
- PROCEDURE link_start;
-
- VAR
- i : BYTE;
- work_str : STRING;
-
- BEGIN;
-
- WITH active_tcb^ DO
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* Init any part of TCB as needed *)
- (*-------------------------------------------------------------------*)
-
- window := window_connect;
-
- (*-------------------------------------------------------------------*)
- (* Remove the channel number (if any) *)
- (*-------------------------------------------------------------------*)
-
- IF tnc_data.str_data[1] = '(' THEN
- tnc_data.str_data := subword(@tnc_data.str_data, 2, 0);
-
- (*-------------------------------------------------------------------*)
- (* Verify that this is indeed a connect request. Give error if not. *)
- (*-------------------------------------------------------------------*)
-
- work_str := subword(@tnc_data.str_data, 1, 2) + ' ';
-
- IF (work_str <> t_to_h_ct) THEN
- BEGIN;
-
- window_write(port_chan_s + 'E:', 'First item is not connect!');
- window_write(port_chan_s + 'E:', work_str);
- window_write(port_chan_s + 'E:', tnc_data.str_data);
-
- cmd_tnc(@disc_cmd, TRUE);
-
- REPEAT
- work_str := garbage_collect_tnc;
- IF LENGTH(work_str) <> 0 THEN
- window_write(port_chan_s + 'G:', tnc_data.str_data);
- UNTIL LENGTH(work_str) = 0;
-
- i := 0;
- REPEAT
- INC(i);
- send_recv_tnc(2);
- IF NOT tnc_null THEN
- window_write(port_chan_s + 'E:', tnc_data.str_data);
- UNTIL tnc_null OR (i > 30);
-
- task_destroy_active;
-
- END;
-
- (*-------------------------------------------------------------------*)
- (* Process the link change *)
- (*-------------------------------------------------------------------*)
-
- link_change;
-
- END;
-
- END;
-
- (*===========================================================================*)
- (* Link Status Change *)
- (*===========================================================================*)
-
- PROCEDURE link_change;
-
- VAR
- connect_call : call_sign_str;
- i : BYTE;
- connect_ssid : ssid_sign_str;
- new_user : BOOLEAN;
- pcpa_port : CHAR;
- this_port : port_block_ptr;
- t1_str : STRING;
- uid_i_current : user_index_ptr;
- work2_str : STRING;
- work3_str : STRING;
-
- {$I BBLCA.PAS}
-
- BEGIN;
-
- WITH active_tcb^ DO
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* Display *)
- (*-------------------------------------------------------------------*)
-
- window_write(port_chan_s + 'L:', tnc_data.str_data);
-
- (*-------------------------------------------------------------------*)
- (* If told to, we will ignore link changes *)
- (*-------------------------------------------------------------------*)
-
- IF tcb_ignore_lc THEN
- EXIT;
-
- (*-------------------------------------------------------------------*)
- (* Remove the channel number (if any) *)
- (*-------------------------------------------------------------------*)
-
- IF tnc_data.str_data[1] = '(' THEN
- tnc_data.str_data := subword(@tnc_data.str_data, 2, 0);
-
- (*-------------------------------------------------------------------*)
- (* Prep the strings *)
- (*-------------------------------------------------------------------*)
-
- work2_str := subword(@tnc_data.str_data, 1, 2) + ' ';
- work3_str := subword(@tnc_data.str_data, 1, 3) + ' ';
-
- (*-------------------------------------------------------------------*)
- (* Handle connect requests or link resets. Rederive user/ssid *)
- (*-------------------------------------------------------------------*)
-
- IF (work2_str = t_to_h_ct) OR
- (work3_str = t_to_h_lrfm) OR
- (work3_str = t_to_h_lrto) THEN
- BEGIN;
-
- (*---------------------------------------------------------------*)
- (* Log it as neededed *)
- (*---------------------------------------------------------------*)
-
- log_data_s('C' + port_chan_s + tnc_data.str_data + ' ' + tcb_name);
-
- (*---------------------------------------------------------------*)
- (* Ignore LINK RESET TO *)
- (*---------------------------------------------------------------*)
-
- IF (work3_str = t_to_h_lrto) OR (work3_str = t_to_h_lrfm) THEN
- EXIT;
-
- (*---------------------------------------------------------------*)
- (* Init any part of TCB as needed *)
- (*---------------------------------------------------------------*)
-
- window := window_connect;
-
- (*---------------------------------------------------------------*)
- (* If port is locked then tell him and hang up *)
- (*---------------------------------------------------------------*)
-
- IF active_port^.port_operate_mode.mode_stop_connect
- OR opt_block.operate_mode.mode_stop_connect THEN
- BEGIN;
- send_message(message_port_conn_off);
- end_session(TRUE);
- END;
-
- (*---------------------------------------------------------------*)
- (* Look up call sign *)
- (*---------------------------------------------------------------*)
-
- find_call;
-
- IF (active_tcb^.uid_data.user_id = '')
- AND (active_tcb^.tcb_type = th_user) THEN
- extract_call
- ELSE
- BEGIN;
- connect_call := active_tcb^.uid_data.user_id;
- connect_ssid := active_tcb^.uid_data.user_ssid;
- END;
-
- (*---------------------------------------------------------------*)
- (* Change to any sub-port as needed *)
- (*---------------------------------------------------------------*)
-
- WITH active_port^ DO
- IF (port_type = port_pcpa) AND (port_num <> pcpa_port) THEN
- BEGIN;
-
- (*---------------------------------------------------------*)
- (* Find the correct port *)
- (*---------------------------------------------------------*)
-
- this_port := main_port;
- WHILE (this_port <> NIL)
- AND (this_port^.port_num <> pcpa_port) DO
- this_port := this_port^.rel_port;
-
- (*---------------------------------------------------------*)
- (* Make sure we have a valid subport *)
- (*---------------------------------------------------------*)
-
- IF this_port = NIL THEN
- BEGIN;
- WRITELN;
- WRITELN('*** FATAL ERROR ***');
- WRITELN('Incoming connect on undefined PC*PA port');
- WRITELN('Defined = ', active_port^.port_num);
- WRITELN('Received = ', pcpa_port);
- HALT;
- END;
-
- (*---------------------------------------------------------*)
- (* Unmark the channel on one port and mark it on the other *)
- (*---------------------------------------------------------*)
-
- i := channel;
-
- (*---------------------------------------------------------*)
- (* Make sure all the port pointers are updated *)
- (*---------------------------------------------------------*)
-
- active_tcb^.tcb_port := this_port;
- active_tcb^.port_chan_s[1] := this_port^.port_char;
- active_port := this_port;
-
- END;
-
- (*---------------------------------------------------------------*)
- (* Get user's data *)
- (*---------------------------------------------------------------*)
-
- uid_i_current := find_uid(connect_call);
-
- (*---------------------------------------------------------------*)
- (* Check for new user *)
- (*---------------------------------------------------------------*)
-
- new_user := uid_i_current = NIL;
-
- IF new_user THEN
- BEGIN;
-
- (*-----------------------------------------------------------*)
- (* Is a new user allowed? *)
- (*-----------------------------------------------------------*)
-
- IF active_port^.port_allow > user_c_nu THEN
- BEGIN;
- send_message(message_not_on_port);
- end_session(TRUE);
- END;
-
- (*-----------------------------------------------------------*)
- (* Put new user in the tables *)
- (*-----------------------------------------------------------*)
-
- uid_init(@active_tcb^.uid_data);
-
- active_tcb^.uid_data.user_id := connect_call;
- active_tcb^.uid_data.user_ssid := connect_ssid;
-
- add_uid(@active_tcb^.uid_data);
-
- END
- ELSE
- active_tcb^.uid_data := get_uid(uid_i_current)^;
-
- (*---------------------------------------------------------------*)
- (* Put in activity report *)
- (*---------------------------------------------------------------*)
-
- IF active_tcb^.tcb_type = th_user THEN
- add_mon_call(@dummy_port, active_port^.port_char,
- uid_data.user_id);
-
- (*---------------------------------------------------------------*)
- (* Bump logon count *)
- (*---------------------------------------------------------------*)
-
- INC(active_tcb^.uid_data.user_l_cnt);
-
- (*---------------------------------------------------------------*)
- (* Show incoming port *)
- (*---------------------------------------------------------------*)
-
- active_tcb^.uid_data.user_port := active_port^.port_char;
-
- (*---------------------------------------------------------------*)
- (* Set up the user class *)
- (*---------------------------------------------------------------*)
-
- IF NOT new_user THEN
- BEGIN;
-
- IF active_tcb^.uid_data.user_class = user_c_nu THEN
- active_tcb^.uid_data.user_class := user_c_uu;
-
- IF active_tcb^.uid_data.user_class > user_c_eu THEN
- active_tcb^.uid_data.user_class := user_c_eu;
-
- IF (active_tcb^.uid_data.user_flag AND user_f_sysop) <> 0 THEN
- active_tcb^.uid_data.user_class := user_c_eu;
-
- IF (active_tcb^.uid_data.user_flag AND user_f_bbs) <> 0 THEN
- active_tcb^.uid_data.user_class := user_c_bu;
-
- END;
-
- (*---------------------------------------------------------------*)
- (* Set up MAXPAC *)
- (*---------------------------------------------------------------*)
-
- max_pac := active_port^.max_pac;
-
- IF uid_data.max_pac <> 0 THEN
- BEGIN;
- IF max_pac > uid_data.max_pac THEN
- max_pac := uid_data.max_pac;
- END
- ELSE
- max_pac := active_port^.dflt_pac;
-
- IF max_pac = 0 THEN
- max_pac := 128;
-
- (*---------------------------------------------------------------*)
- (* Finish TCB setup *)
- (*---------------------------------------------------------------*)
-
- last_l_time := uid_data.user_l_time;
-
- tcb_connect := TRUE;
-
- EXIT;
-
- END; (*----- End of connect/link reset ----------------------------*)
-
- (*-------------------------------------------------------------------*)
- (* Handle link drops *)
- (*-------------------------------------------------------------------*)
-
- IF (work2_str = t_to_h_disc) OR
- (work3_str = t_to_h_lf) THEN
- BEGIN;
-
- (*---------------------------------------------------------------*)
- (* Don't log terminal sessions or modem answers *)
- (*---------------------------------------------------------------*)
-
- IF (tcb_type <> th_opr_terminal) AND (tcb_type <> th_answer) THEN
- log_data_s('D' + port_chan_s + tnc_data.str_data);
-
- (*---------------------------------------------------------------*)
- (* Update user's information *)
- (*---------------------------------------------------------------*)
-
- IF tcb_connect AND (tcb_type = th_user) THEN
- BEGIN;
- uid_data.user_last := current_day_time;
- IF active_tcb^.last_l_time
- > active_tcb^.uid_data.user_l_time THEN
- active_tcb^.uid_data.user_l_time := active_tcb^.last_l_time;
- update_uid(@uid_data);
- END;
-
- (*---------------------------------------------------------------*)
- (* Mark channel idle *)
- (*---------------------------------------------------------------*)
-
- i := channel;
-
- IF (i <> 0) AND (i <= active_port^.max_chan) THEN
- active_port^.connected^[i] := NIL;
-
- (*---------------------------------------------------------------*)
- (* Destroy current task. This call never returns! *)
- (*---------------------------------------------------------------*)
-
- task_destroy_active;
-
- END;
-
- (*-------------------------------------------------------------------*)
- (* Log anything left *)
- (*-------------------------------------------------------------------*)
-
- log_data_s('A' + port_chan_s + tnc_data.str_data);
-
- END;
-
- END;
-
- (*===========================================================================*)
- (* Link Change pending on channel *)
- (*===========================================================================*)
-
- PROCEDURE link_pending;
-
- BEGIN;
- send_recv_tnc(4);
- WITH active_tcb^ DO
- IF tnc_type <> t_to_h_links THEN
- WRITELN('LC poll bad -- ', tnc_type, ' -- ', port_chan_s);
- link_change;
- task_switch;
- END;
-
- END.